      1  /**

      2     A bank consisting of multiple bank accounts.

      3  */

      4  public class Bank

      5  {

      6     private BankAccount[] accounts;

      7

      8     /**

      9        Constructs a bank account with a given number of accounts.

     10        @param size the number of accounts

     11     */

     12     public Bank(int size)

     13     {

     14        accounts = new BankAccount[size];

     15        for (int i = 0; i < accounts.length; i++)

     16        {

     17           accounts[i] = new BankAccount();

     18        }

     19     }

     20

     21     /**

     22        Deposits money into a bank account.

     23        @param accountNumber the account number

     24        @param amount the amount to deposit

     25     */

     26     public void deposit(int accountNumber, double amount)

     27     {

     28        BankAccount account = accounts[accountNumber];

     29        account.deposit(amount);

     30     }

     31

     32     /**

     33        Withdraws money from a bank account.

     34        @param accountNumber the account number

     35        @param amount the amount to withdraw

     36     */

     37     public void withdraw(int accountNumber, double amount)

     38     {

     39        BankAccount account = accounts[accountNumber];

     40        account.withdraw(amount);

     41     }

     42

     43     /**

     44        Gets the balance of a bank account.

     45        @param accountNumber the account number

     46        @return the account balance

     47     */

     48     public double getBalance(int accountNumber)

     49     {

     50        BankAccount account = accounts[accountNumber];

     51        return account.getBalance();

     52     }

     53  }

     54

     55